package iterables;

import interfaces.Expresion;
import java.util.Iterator;

//TODO: Pr4 Ejer 2 A
public class IterableExpresion<T1,T2> implements Iterable<T2> {

	private Iterable<T1> it1;
	private Expresion<T1,T2> e;
	public IterableExpresion(Iterable<T1>i1, Expresion<T1,T2> e1) {
		it1=i1;
		e=e1;
	}
	public Iterator<T2> iterator(){
		return new IteradorExpresion();
	}
	//TODO: Pr4 Ejer 2 B
	private class IteradorExpresion implements Iterator<T2> {
		private Iterator<T1> i1;

		public IteradorExpresion(){
			i1 = it1.iterator();
		}
		public boolean hasNext(){
			return (i1.hasNext());
		}
		public T2 next() {
			T1 o= i1.next();
			return e.exp(o);
		}
		public void remove() {
		}
	}
}


